import React from 'react'
import {connect} from 'react-redux'
import {Redirect} from 'react-router-dom'
import { Layout, } from 'antd';




import Header from '../../compnents/header/header'
import Leftnav from '../../compnents/leftnav/leftnav'
import './admin.less'

const {  Footer, Sider, Content } = Layout;


class Admin extends React.Component{
    
   


   
    render(){
         const user = this.props.user
           // 如果内存没有存储user ==> 当前没有登陆
         if(!user ||!user._id){
              // 自动跳转到登陆(在render()中)
            return <Redirect to='/login'/>
         }

        

        return (
            <Layout style={{height:'100%'}}>
                <Sider> 
                    <div className='logo'>测试系统</div>
                    <Leftnav></Leftnav>
                </Sider>
                <Layout>
                    <Header>Header</Header>
                    <Content>Content</Content>
                    <Footer>Footer</Footer>      
                </Layout>    
          </Layout>
        )
    }
}


export default connect(
    state =>({user:state.user}),
    {}
)(Admin);
